import requireDirectory from 'require-directory'
// 路由
import router from 'koa-router'
// 自定加载路由：避免了多很多路由文件，而需要一个个去加载
export default function loadRoutes (app: any) {
  console.log(app)
  requireDirectory(module, '../routes', {
    visit: (obj: any) => {
      console.log(obj)
      if (obj instanceof router) {
        app.use(obj.routes(), obj.allowedMethods())
      }
    }
  })
}